"""
Case Type   : 系统内部使用工具
Case Name   : gs_ctl：指定参数--help,显示命令行参数信息
Create At   : 2022-07-28
Owner       : liu-tong-8848
Description :
    1.执行gs_ctl --help的命令
Expect      :
    1.成功
History     :
"""

import unittest
from testcase.utils.Logger import Logger
from yat.test import Node
from yat.test import macro
import os


class Tools(unittest.TestCase):
    def setUp(self):
        self.logger = Logger()
        self.userNode = Node('PrimaryDbUser')
        self.DB_ENV_PATH = macro.DB_ENV_PATH

    def test_systools(self):
        self.logger.info(f'-----{os.path.basename(__file__)}' + ' start-----')

        text = '--step1:执行gs_ctl --version的命令；expect：成功--'
        self.logger.info(text)
        excute_cmd1 = f'source {self.DB_ENV_PATH};' \
                      f'gs_ctl --version'
        self.logger.info(excute_cmd1)
        msg1 = self.userNode.sh(excute_cmd1).result()
        self.logger.info(msg1)
        self.assertIn('gs_ctl (openGauss', msg1, text + '执行失败')

    def tearDown(self):
        self.logger.info(
            f'-----{os.path.basename(__file__)}' + ' end-----')

